home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PASCSRC.ZIP / IFDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-15  |  1KB  |  38 lines

  1.                                 (* Chapter 4 - Program 2 *)
  2. program Demonstrate_Conditional_Branching;
  3.  
  4. var One,Two,Three  : integer;
  5.  
  6. begin  (* main program *)
  7.    One := 1;           (* these are to have some numbers *)
  8.    Two := 2;           (* to use for illustrations *)
  9.    Three := 3;
  10.  
  11.    if Three = (One + Two) then        (* Example 1 *)
  12.       Writeln('three is equal to one plus two');
  13.  
  14.    if Three = 3 then begin            (* Example 2 *)
  15.       Write('three is ');
  16.       Write('equal to ');
  17.       Write('one plus two');
  18.       Writeln;
  19.    end;
  20.  
  21.    if Two = 2 then                    (* Example 3 *)
  22.       Writeln('two is equal to 2 as expected')
  23.    else
  24.       Writeln('two is not equal to 2... rather strange');
  25.  
  26.    if Two = 2 then                    (* Example 4 *)
  27.       if One = 1 then
  28.          Writeln('one is equal to one')
  29.       else
  30.          Writeln('one is not equal to one')
  31.    else
  32.       if Three = 3 then
  33.          Writeln('three is equal to three')
  34.       else
  35.          Writeln('three is not equal to three');
  36.  
  37. end.  (* main program *)
  38.